package com.atguigu.tingshu.user.service.impl;

import com.atguigu.tingshu.user.service.MqOpsService;
import com.atguigu.tingshu.user.strategy.ProcessDiffPayRecord;
import com.atguigu.tingshu.vo.user.UserPaidRecordVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * Description:
 *
 * @author Yanxinhao on 2025/2/13
 */
@Service
public class MqOpsServiceIml implements MqOpsService {

    @Autowired
    private Map<String, ProcessDiffPayRecord> processDiffPayRecordMap;

    /**
     * 修改用户付费记录
     * @param userPaidRecordVo 用户付费记录
     */
    @Override
    public void updateUserPaidRecord(UserPaidRecordVo userPaidRecordVo) {

        //1.获取itemType 即用户消费类型,或是专辑,或是音频,或是vip
        String itemType = userPaidRecordVo.getItemType();

        //2.我们使用策略设计模式,使用processDiffPayRecordMap来获取具体来执行业务方法的策略对象
        ProcessDiffPayRecord processDiffPayRecord = processDiffPayRecordMap.get(itemType);
        processDiffPayRecord.processPayRecord(userPaidRecordVo);

    }
}